package com.wiscamp.ninechapters.problems.infrastructure.converters;

import com.wiscamp.ninechapters.problems.domain.models.problems.answers.Answer;
import com.wiscamp.ninechapters.problems.domain.models.problems.problems.KnowledgePointName;
import com.wiscamp.ninechapters.problems.domain.models.problems.problems.Problem;
import com.wiscamp.ninechapters.problems.domain.models.problems.problems.ProblemKnowledgePoint;
import com.wiscamp.ninechapters.problems.domain.models.problems.problems.Stem;
import com.wiscamp.ninechapters.problems.domain.models.problems.questions.Option;
import com.wiscamp.ninechapters.problems.domain.models.problems.questions.Question;
import com.wiscamp.ninechapters.problems.domain.models.problems.questions.Solution;
import com.wiscamp.ninechapters.problems.infrastructure.po.problems.*;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgePoint;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        unmappedSourcePolicy = ReportingPolicy.IGNORE,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface ProblemConverter {

    ProblemConverter Instance = Mappers.getMapper(ProblemConverter.class);

    // region problem
    ProblemPO toProblemPO(Problem entity);

    ProblemPO toProblemPO(Problem entity, @MappingTarget ProblemPO po);

    Problem toProblem(ProblemPO po);

    Problem toProblemByView(ProblemView view);
    // endregion


    // region stem
    StemPO toStemPO(Stem entity);

    StemPO toStemPO(Stem entity, @MappingTarget StemPO po);

    Stem toStem(StemPO po);
    // endregion


    // region question
    QuestionPO toQuestionPO(Question entity);

    QuestionPO toQuestionPO(Question entity, @MappingTarget QuestionPO po);

    Question toQuestion(QuestionPO po);

    Question toQuestionByView(QuestionView view);
    // endregion


    // region option
    QuestionOptionPO toOptionPO(Option entity);

    QuestionOptionPO toOptionPO(Option entity, @MappingTarget QuestionOptionPO po);

    Option toOption(QuestionOptionPO po);
    // endregion

    // region option
    QuestionAnswerPO toAnswerPO(Answer entity);

    QuestionAnswerPO toAnswerPO(Answer entity, @MappingTarget QuestionAnswerPO po);

    Answer toAnswer(QuestionAnswerPO po);
    // endregion

    // region solution
    QuestionSolutionPO toSolutionPO(Solution entity);

    QuestionSolutionPO toSolutionPO(Solution entity, @MappingTarget QuestionSolutionPO po);

    Solution toSolution(QuestionSolutionPO po);

    // endregion

    KnowledgePointName toKnowledgePointName(KnowledgePoint entity);

    KnowledgePointName toKnowledgePointName(ProblemKnowledgePoint entity);
}
